//
//  ViewController.m
//  Tool
//
//  Created by 积分宝 on 16/8/18.
//  Copyright © 2016年 积分宝. All rights reserved.
//

#import "ViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
#import "UIcolor+TSFColor.h"
#import "NSString+TSFString.h"
#import "UILabel+FlickerNumber.h"
#import "UIView+JFBExtension.h"
#import "NSData+AES_Encryption.h"
#import "Masonry.h"
#import "UINavigationController+WXSTransition.h"
@interface ViewController ()<UIWebViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self method3];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:@"值" forKey:@"key"];
  
    NSLog(@"===   %@",[self returnJiaMi:@""]);
    
    NSString *s1  =[self returnJiaMi:@""];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(20, 100, 100, 40)];
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(xx) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
    UIButton *button1 = [[UIButton alloc]initWithFrame:CGRectMake(20, 180, 100, 40)];
    button1.backgroundColor = [UIColor redColor];
    [button1 addTarget:self action:@selector(xxxx) forControlEvents:UIControlEventTouchUpInside];
    button1.backgroundColor = [UIColor colorWithHexString:@"456fff"];
    [self.view addSubview:button1];
    
    NSString *phone = @"17858858540";
    NSString *email = @"345499860@qq.com";
    BOOL aa = [phone validatePhone];
    BOOL bb = [email isEmail];
    
    BOOL cc = [email validatePhone];
    BOOL dd = [phone isEmail];
    
    
    NSData *ca = [s1 dataUsingEncoding:NSUTF8StringEncoding];
    ca = [ca AES256DecryptWithKey:@"xiapingpingwoain"];
    //ca = [ca AES256DecryptWithKey:@"xiapingpingwoain"];
    
    NSString *nima = [[NSString alloc]initWithData:ca encoding:NSUTF8StringEncoding];
    NSLog(@"%@==",nima);
  
   // NSLog(@"%d  ===  %d ==  %d==%d",aa,bb,cc,dd);
   
    UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
    lab.backgroundColor = [UIColor orangeColor];
    lab.center = self.view.center;
    lab.textAlignment = NSTextAlignmentCenter;
    lab.text = @"1";
  //  [lab fn_setNumber:[NSNumber numberWithInt:3000] duration:3];
   // [lab fn_setNumber:@(30000) duration:4 format:@".2f" attributes:nil];
    
    id attributes = @[[NSDictionary fn_dictionaryWithAttribute:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}
                                                         range:NSMakeRange(0, 4)],
                      [NSDictionary fn_dictionaryWithAttribute:@{NSForegroundColorAttributeName:[UIColor whiteColor]}
                                                         range:NSMakeRange(0, 4)]];
    
      [lab fn_setNumber:@(3000) duration:1.0f format:@"%.2f" attributes:attributes];
    [self.view addSubview:lab];
    
    
    
    
    
    
    
    
    UIView *view3 = [[UIView alloc]init];
    view3.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:view3];
    [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.height.mas_equalTo(@50);
        make.width.mas_equalTo(@234);
        make.top.mas_equalTo(@64);
        make.left.mas_equalTo(@100);
        
    }];
    
    
    
    
}

#pragma mark - 加密后返回值

-(NSString *)returnJiaMi:(NSString *)text{
    
    NSData *tata =  [text dataUsingEncoding:NSUTF8StringEncoding];
    [tata AES256EncryptWithKey:@"xiapingpingwoain"];
    
    tata =  [tata AES256EncryptWithKey:@"xiapingpingwoain"];
    
    NSString *s = [NSString stringWithFormat:@"%@",tata];
    
    s = [s stringByReplacingOccurrencesOfString:@" " withString:@""];
    　NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"<"];
    NSCharacterSet *set1 = [NSCharacterSet characterSetWithCharactersInString:@">"];
    s= [s stringByTrimmingCharactersInSet:set];
    s =[s stringByTrimmingCharactersInSet:set1];
    
    s= [self toUpper:s];
    
    return s;
}

#pragma mark - 转换成大写字母
-(NSString *)toUpper:(NSString *)str{
    for (NSInteger i=0; i<str.length; i++) {
        if ([str characterAtIndex:i]>='a'&[str characterAtIndex:i]<='z') {
            //A  65  a  97
            char  temp=[str characterAtIndex:i]-32;
            NSRange range=NSMakeRange(i, 1);
            str=[str stringByReplacingCharactersInRange:range withString:[NSString stringWithFormat:@"%c",temp]];
        }
    }
    return str;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"36.jpg"]
                                        //          forBarMetrics:UIBarMetricsDefault];
}
-(void)xx{
    TwoViewController *view = [[TwoViewController alloc]init];
    [self.navigationController pushViewController:view animated:YES];
    
    
//    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
//    NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=614304963&version=1&src_type=web"];
//    NSURLRequest *request = [NSURLRequest requestWithURL:url];
//    webView.delegate = self;
//    [webView loadRequest:request];
//    [self.view addSubview:webView];
    
    
}
-(void)xxxx{
    ThreeViewController *view = [[ThreeViewController alloc]init];
    [self.navigationController wxs_pushViewController:view animationType:arc4random()%18];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)method3{
    UIImageView *imageViews = [[UIImageView alloc]initWithFrame:CGRectMake(100, 400, 100, 100)];
    imageViews.image = [UIImage imageNamed:@"36.jpg"];
    /*
     第二个参数可以选择性的对哪一个部位做圆角处理
     UIRectCornerTopLeft
     UIRectCornerTopRight
     UIRectCornerBottomLeft
     UIRectCornerBottomRight
     UIRectCornerAllCorners
     */
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageViews.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:imageViews.bounds.size];
    
    
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    //设置大小
   // maskLayer.frame = CGRectMake(0, 0, 0, 0);

    //设置图形的样子
    maskLayer.path = maskPath.CGPath;
    maskLayer.borderWidth = .2;
    //最终对imageViews的设置
    
    imageViews.layer.mask = maskLayer;
    
    [self.view addSubview:imageViews];
    
    
}


























@end
